<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
      Vue3 在组件上使用 v-model="xxx" 的展示形式
        :modelValue="xxx"
        @update:modelValue="xxx = $event"

         v-model="xxx"  <=> v-model:modelValue="xxx"

      Vue3 在组件上使用 v-model:xxx="yyy" 的展示形式
        :xxx="yyy"
        @update:xxx="yyy = $event"
        
     -->
    <div id="app">
      <hello :xxx="name" @update:xxx="name = $event"></hello>
    </div>

    <script src="./lib/vue.global.js"></script>
    <script>
      const { ref } = Vue;

      const app = Vue.createApp({
        setup() {
          const name = ref("张三");

          return {
            name,
          };
        },
      });

      app.component("hello", {
        template: `
          <div>
            <h1>Hello - {{ xxx }}</h1>  
            <button @click="$emit('update:xxx', '里斯')">修改父组件的name</button>
          </div>
        `,

        props: ["xxx"],

        emits: ["update:xxx"],

        setup(props, { attrs }) {
          console.log("props", props);
          console.log("attrs", attrs);
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
